package com.edol.painting.utils;

import android.app.Activity;
import android.util.DisplayMetrics;

import java.lang.reflect.Field;

public class Constant {
	
	public static final float PAINT_CANVAS_VIRTUAL_W = 9.0f;
	public static final float PAINT_CANVAS_VIRTUAL_H = 16.0f;

	public static final int PAINTING_LIST_NUM_COLUMNS = 2;
	
	public static final int PAINTER_TITLE_SIZE = 22;
	
	public static final float M065_TO_M040_RATIO = 1.35f;

    public static final int PAINTER_FIRST_RUN = 0;
    public static final int PAINTER_TOOL_TIP_START = 1;
    public static int START_TIP_COUNT = 0;
    public static int EDIT_TIP_COUNT = 0;
    public static int PAINTER_TOOL_TIP = -1;

	public static int PAINTING_WIDTH;
	public static int PAINTING_HEIGHT;
	public static int ACTIONBAR_HEIGHT;
	public static int STATUS_BAR_HEIGHT = 96;
	public static int PAINTING_THUMB_WIDTH;
	public static int PAINTING_THUMB_HEIGHT;
	
	public static void initCommonValue(Activity activity) {
		// Calculate StatusBar height
		try {
			Class<?> c = Class.forName("com.android.internal.R$dimen");
			Object obj = c.newInstance();
			Field field = c.getField("status_bar_height");
			int x = Integer.parseInt(field.get(obj).toString());
			STATUS_BAR_HEIGHT = activity.getResources().getDimensionPixelSize(x);
		} catch (Exception e1) {
		}

		DisplayMetrics dm = activity.getResources().getDisplayMetrics();
		PAINTING_WIDTH = dm.widthPixels;
		PAINTING_HEIGHT = (int)((PAINT_CANVAS_VIRTUAL_H * PAINTING_WIDTH) / PAINT_CANVAS_VIRTUAL_W);
		Constant.PAINTING_THUMB_WIDTH = Constant.PAINTING_WIDTH / Constant.PAINTING_LIST_NUM_COLUMNS;
		Constant.PAINTING_THUMB_HEIGHT = Constant.PAINTING_THUMB_WIDTH * Constant.PAINTING_HEIGHT / Constant.PAINTING_WIDTH;
	}

	public static final int BRUSH_WIDTH_SEEKBAR_MAX = 42;
	
	public static final int EYEDROPPER_DST_OFFSET = 400;
	public static final int EYEDROPPER_SRC_WIDTH = 300;
	public static final int EYEDROPPER_MAGNIFIER_SHADOW_WIDTH = 9;
	public static final int EYEDROPPER_MAGNIFIER_RADIUS = 4;
	public static final int EYEDROPPER_CANCEL_HEIGHT = 122;
	
	public static final int PAINTING_EDIT_TOAST_STATE_DEFAULT = -1;
	public static final int PAINTING_EDIT_TOAST_STATE_INSERT_FAIL = 0;
	public static final int PAINTING_EDIT_TOAST_STATE_COPY_FAIL = 1;
	
	public static final int PAINTING_PAGER_ANIM_DURATION = 400;
	public static final int PAINTING_EDIT_ANIM_DURATION = 700;
	
	public static final int PAINTING_EDIT_TOOL_ANIM_DURATION = 150;
    public static final int PAINTING_EDIT_CHANGE_BACKGROUND_FRAME = 21;
	
	public static final int COLOR_PICK_SEEKBAR_WIDTH = 370;
	public static final int COLOR_PICK_SEEKBAR_HEIGHT = 69;
	
	public static final float PREF_BRUSH_COLOR_RING_COUNT = 0;
	public static final float PREF_BRUSH_COLOR_SATURATION = 0.1f;
	public static final float PREF_BRUSH_COLOR_LIGHT = 0.9f;
	
	public static final String PAINTER_SHARED_PREFERENCES = "com.edol.dma";
	public static final String PAINTING_START_TIP = "start_tip";
	public static final String PAINTING_EDIT_TIP = "edit_tip";
	public static final String ARG_KEY_PAINTING_ID = "painting_id";
	public static final String ARG_KEY_THEME_ID = "theme_id";
	public static final String ARG_KEY_PAINTING_PAGE_INDEX = "painting_page_index";
	public static final String ARG_KEY_FROM_PAGER = "from_pager";
	
	public static final String PAINTINGS_DIR = "EasyDoodles";
	public static final String PAINTER_TEMP_DIR = "Temps";
	public static final String PAINTER_EXPORT_DIR = "EasyDoodle";
	
	public static final String PAINTING_FILE_EXTENSION = ".png";
	public static final String THUMB_FILE_EXTENSION = ".thumb";
	
	public static final String LIST_SELECTION_BUTTON_VISIBLE = "list_selection_button_visible";
	
	public static final String PREF_BRUSH_TYPE = "brush_type";
	public static final String PREF_BRUSH_WIDTH = "brush_width";
	public static final String PREF_BRUSH_ALPHA = "brush_alpha";
	public static final String PREF_ERASER_TYPE = "eraser_type";
	public static final String PREF_ERASER_WIDTH = "eraser_width";
	public static final String PREF_ERASER_ALPHA = "eraser_alpha";
	public static final String PREF_TEXTURE_ALPHA = "texture_alpha";

	public static final String PREF_BRUSH_COLOR_RING_UNIT = "brush_color_ring_unit";
	public static final String PREF_BRUSH_COLOR_SQUARE_UNIT_X = "brush_color_square_unit_x";
	public static final String PREF_BRUSH_COLOR_SQUARE_UNIT_Y = "brush_color_square_unit_y";
	public static final String PREF_BRUSH_OLD_COLOR = "brush_old_color";
	
	
	public static final String PREF_EDIT_BACKGROUND_COLOR_RING_UNIT = "edit_background_color_ring_unit";
	public static final String PREF_EDIT_BACKGROUND_COLOR_SQUARE_UNIT_X = "edit_background_color_square_unit_x";
	public static final String PREF_EDIT_BACKGROUND_COLOR_SQUARE_UNIT_Y = "edit_background_color_square_unit_y";
	
	public static final String PREF_SAMPLE_GENERATED = "sample_generated";
	//用户引导,长按提取颜色
	public static final String GUIDE_COLOR_PICKER = "guide_color_picker";

	public static final String PREF_FILL_TYPE = "texture_type";
	
	public static final String EXTRA_REQUEST_RESULT_FROM_CHOOSERACTIVITY = "android.intent.extra.requset_result";
	
	public static final int REQUEST_SHARE = 5;
		
	public static final float PI = 3.1415927f;

	public static final int BRUSH_PENCIL_MIN_WIDTH = 4;
	public static final int BRUSH_PENCIL_MAX_WIDTH = 32;
	public static final int BRUSH_PENCIL_MIN_ALPHA = 25;
	public static final int BRUSH_PENCIL_MAX_ALPHA = 255;
	public static final int BRUSH_PENCIL_DEFAULT_WIDTH = 6;
	public static final int BRUSH_PENCEL_DEFAULT_ALPHA = 230;

	public static final int BRUSH_PEN_MIN_WIDTH = 3;
	public static final int BRUSH_PEN_MAX_WIDTH = 60;
	public static final int BRUSH_PEN_MIN_ALPHA = 10;
	public static final int BRUSH_PEN_MAX_ALPHA = 255;
	public static final int BRUSH_PEN_DEFAULT_WIDTH = 10;
	public static final int BRUSH_PEN_DEFAULT_ALPHA = 255;

	public static final int BRUSH_WATERCOLOR_MIN_WIDTH = 35;
    public static final int BRUSH_WATERCOLOR_1080P_MAX_WIDTH = 59; /*85->58*/
    public static final int BRUSH_WATERCOLOR_1440P_MAX_WIDTH = 50;
	public static final int BRUSH_WATERCOLOR_MIN_ALPHA = 6;
	public static final int BRUSH_WATERCOLOR_MAX_ALPHA = 177;
	public static final int BRUSH_WATERCOLOR_DEFAULT_WIDTH = 44;
	public static final int BRUSH_WATERCOLOR_DEFAULT_ALPHA = 152;
	public static final int BRUSH_TEXTURE_ALPHA = 150;

	public static final int BRUSH_CHALK_MIN_WIDTH = 7;
	public static final int BRUSH_CHALK_MAX_WIDTH = 61;
	public static final int BRUSH_CHALK_MIN_ALPHA = 24;
	public static final int BRUSH_CHALK_MAX_ALPHA = 255;
	public static final int BRUSH_CHALK_DEFAULT_WIDTH = 32;
	public static final int BRUSH_CHALK_DEFAULT_ALPHA = 245;

	public static final int BRUSH_MARKER_MIN_WIDTH = 27;
	public static final int BRUSH_MARKER_MAX_WIDTH = 115;
	public static final int BRUSH_MARKER_MIN_ALPHA = 7;
	public static final int BRUSH_MARKER_MAX_ALPHA = 144;
	public static final int BRUSH_MARKER_DEFAULT_WIDTH = 54;
	public static final int BRUSH_MARKER_DEFAULT_ALPHA = 170;

	public static final int BRUSH_SOFT_CHARCOAL_MIN_WIDTH = 14;
	public static final int BRUSH_SOFT_CHARCOAL_MAX_WIDTH = 80;
	public static final int BRUSH_SOFT_CHARCOAL_MIN_ALPHA = 70;
	public static final int BRUSH_SOFT_CHARCOAL_MAX_ALPHA = 255;
	public static final int BRUSH_SOFT_CHARCOAL_DEFAULT_WIDTH = 55;
	public static final int BRUSH_SOFT_CHARCOAL_DEFAULT_ALPHA = 214;

	public static final int BRUSH_ERASER_MIN_WIDTH = 10;
	public static final int BRUSH_ERASER_MAX_WIDTH = 180;
	public static final int BRUSH_ERASER_MIN_ALPHA = 10;
	public static final int BRUSH_ERASER_MAX_ALPHA = 255;
	public static final int BRUSH_ERASER_DEFAULT_WIDTH = 90;
	public static final int BRUSH_ERASER_DEFAULT_ALPHA = 255;

	public static final int BRUSH_SOFT_ERASRE_MIN_WIDTH = 10;
	public static final int BRUSH_SOFT_ERASRE_MAX_WIDTH = 180;
	public static final int BRUSH_SOFT_ERASRE_MIN_ALPHA = 10;
	public static final int BRUSH_SOFT_ERASRE_MAX_ALPHA = 255;
	public static final int BRUSH_SOFT_ERASRE_DEFAULT_WIDTH = 90;
	public static final int BRUSH_SOFT_ERASRE_DEFAULT_ALPHA = 255;
	
	public static final int BRUSH_TEXTURE_MIN_ALPHA = 20;
	public static final int BRUSH_TEXTRUE_MAX_ALPHA = 255;


	//意见反馈每天最多提交的次数
	public static final int FEEDBACK_SUBMIT_LIMIT = 3; //3 times per day
	public static final String FEEDBACK_SUBMIT_LAST_TIME = "feedback_submit_last_time";
	public static final String FEEDBACK_SUBMIT_COUNT = "feedback_submit_count";

}
